package me.yobol.greentable.listener;

import java.sql.SQLException;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import me.yobol.greentable.bean.UserBean;
import me.yobol.greentable.service.UserService;

/**
 * @author Yobol
 *
 */
public class UserSessonListener implements HttpSessionListener{
	
	@Override
	public void sessionCreated(HttpSessionEvent se) {
		
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		UserBean user = new UserBean();
		user.setUserId((int)se.getSession().getAttribute("uId"));
		try {
			UserService.loginOut(user);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	

}
